﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tilver.Coder;
using System.Xml.Serialization;

namespace Tilver.Coder.Core
{
    /// <summary>
    /// 列
    /// </summary>
    [Serializable]
    public class CoderColumn : CoderDataObject, ICloneable
    {
        /// <summary>
        /// 所属表
        /// </summary>
        [XmlIgnore]
        public CoderTable Table { get; set; }
        ///// <summary>
        ///// 所属表名
        ///// </summary>
        //public string TableName { get; set; }
        /// <summary>
        /// 类型
        /// </summary>
        public override DataObjectTypeEnum DataType
        {
            get { return DataObjectTypeEnum.Column; }
        }
        /// <summary>
        /// 是否自增列
        /// </summary>
        public bool IsIdentity { get; set; }
        /// <summary>
        /// 是否主健
        /// </summary>
        public bool IsPrimaryKey { get; set; }
        /// <summary>
        /// 是否外健
        /// </summary>
        public bool IsForeignKey { get; set; }
        /// <summary>
        /// 是否唯一健
        /// </summary>
        public bool IsUnique { get; set; }

        #region ICloneable 成员

        public object Clone()
        {
            return new CoderColumn
            {
                Name = this.Name,
                AllowDBNull = this.AllowDBNull,
                AllowGenerateEnum = this.AllowGenerateEnum,
                CodeName = this.CodeName,
                CSharpType = this.CSharpType,
                DbType = this.DbType,
                DefaultValue = this.DefaultValue,
                Description = this.Description,
                IsEnumType = this.IsEnumType,
                NativeType = this.NativeType,
                Precision = this.Precision,
                Scale = this.Scale,
                Size = this.Size,
                State = this.State
            };
        }

        #endregion
    }
}
